package com.jida.hadoop.mr.user7;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
 
import java.io.IOException;
 
public class DxProStatisticDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        //设置map和reduce内存使用大小
        conf.set("mapreduce.map.memory.mb", "3072");
        conf.set("mapreduce.reduce.memory.mb", "2048");
        Job job = Job.getInstance(conf, "Dx_ProStatistic");
        job.setJarByClass(DxProStatisticDriver.class);
        //map和reduce设置
        job.setMapperClass(MapperDxProStatistic.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
 
        job.setReducerClass(ReducerDxProStatistic.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
 
        //输入路径
        FileInputFormat.addInputPath(job,new Path("file:///D://测试数据//dx//06.DxProMatch/part-r-00*"));
        //输出路径
        FileOutputFormat.setOutputPath(job, new Path("file:///D://测试数据//dx//07.DxProStatistic"));
        //提交作业 判断退出条件（0正常退出，1非正常退出）
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

